package com.econ.powercloud.ems.controller;

import com.econ.powercloud.common.base.facade.pojo.MsgResult;
import com.econ.powercloud.ems.config.InitParameter;
import com.econ.powercloud.ems.service.biz.EnergyStationService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author : zjf
 * @Description : 内存缓存刷新controller
 * @Date : 2022/6/8 8:50
 * @Modified by : zjf
 */
@Api(tags = "缓存刷新")
@RestController
@RequestMapping(value = "/api/v2/cache/refresh")
public class CacheRefreshController extends ApiBaseController {
    @Autowired
    private InitParameter initParameter;
    @Autowired
    private EnergyStationService energyStationService;

    @ApiOperation(value = "刷新初始化内存map")
    @GetMapping(value = "initRefresh")
    public MsgResult initRefresh(){
        initParameter.init();
        return successHandler("刷新初始化内存成功！");
    }

    @ApiOperation(value = "更新储能站的计算数据")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "stationId", value = "储能站id", dataType = "String")
    })
    @PutMapping(value = "updateStationCalData")
    public MsgResult updateStationCalData(@RequestParam("stationId")String stationId){
        energyStationService.updateStationCalData(stationId);
        initParameter.init();
        return successHandler("更新储能站的计算数据成功!");
    }

    @ApiOperation(value = "更新储能站的结构图数据")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "stationId", value = "储能站id", dataType = "String")
    })
    @PutMapping(value = "updateStationStructure")
    public MsgResult updateStationStructure(@RequestParam("stationId")String stationId){
        energyStationService.updateStationStructure(stationId);
        initParameter.init();
        return successHandler("更新储能站的结构图数据成功!");
    }

}
